//
//  ViewController.m
//  QQlogin
//
//  Created by 楼楚 on 15/10/29.
//  Copyright © 2015年 Chu Lou. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *userName;
@property (weak, nonatomic) IBOutlet UITextField *pwdText;

@end

@implementation ViewController
- (IBAction)login {
    
    NSLog(@"%s 用户名：%@ 密码：%@",__FUNCTION__,self.userName.text,self.pwdText.text);
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.userName becomeFirstResponder];
}
#pragma mark - 文本框代理方法
//在文本框中按回车的处理
- (BOOL) textFieldShouldReturn:(UITextField *)textField
{
    NSLog(@"%@",textField);
//    如果光标在用户名，切换到密码
    if (textField == self.userName) {
//密码成为第一响应者
        [self.pwdText becomeFirstResponder];
    } else if (textField ==  self.pwdText){
//        如果是密码，直接调用登录方法
        [self login];
//        关闭键盘
//        [self.view endEditing:YES];
//        让密码文本框关闭键盘
        [textField resignFirstResponder];
        
    }
    
    return YES;
}


@end
